home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / calctp.com / CALC.DOC < prev    next >
Encoding:
Text File  |  1989-11-04  |  22.2 KB  |  594 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.      CALC.TPU (2.0)            TP5.X Compiled Unit             CALC.TPU (2.0)
  7.  
  8.  
  9.           
  10.      UNIT NAME 
  11.           
  12.           CALC.TPU - Version 1.0 for Turbo Pascal Version 5.X.
  13.  
  14.           Version 1.0 Released July 30, 1988.
  15.           Version 1.1 Released Aug. 15, 1988, corrects window removal.
  16.           Version 2.0 Released Dec. 27, 1988. TP5.X and TP4 compatible.
  17.  
  18.           
  19.      PROGRAMMER 
  20.  
  21.           
  22.           Timothy B. Coleman
  23.           11115 Kenmoor Drive
  24.           Detroit, Michigan 48205
  25.  
  26.           
  27.  
  28.      GENERAL DESCRIPTION 
  29.           
  30.  
  31.           This Unit file  will  allow  a Turbo Pascal Ver. 5.X (TP5.X)
  32.           programmer to add a Four  Function  Calculator  to any TP5.X
  33.           program with  the declaration, "Uses Calc, Meta;".  CALC.TPU
  34.           contains  the  calculator  "engine"  to  perform  a  perfect
  35.           emulation of  a handheld four function calculator.  The unit
  36.           can  make  the  result  of  a  calculation  available,   for
  37.           insertion  into the application below the calculator window.
  38.           Meta is a unit that contains the  Metaphor  or  image  of  a
  39.           calculator.  
  40.           
  41.           Three  example  calculator Metaphor tpu files and the source
  42.           code are included, or the developer may create its META.TPU, 
  43.           using one  of  the  included  files  as  an  example.    The
  44.           programmer   then   decides  whether  or  not  a  calculator
  45.           metaphor, key help screen, or simply a small  window,  where
  46.           only  the  numbers  entered  and  results  are displayed, is
  47.           appropriate for the given application.   Or  the  programmer
  48.           may  decide to give the user a choice of a small window or a
  49.           metaphor in the programs installation procedures.  
  50.           
  51.           The programmer can elect to use the unit in its default form
  52.  
  53.  
  54.  
  55.  
  56.                                       -1-
  57.  
  58.  
  59.  
  60.  
  61.  
  62.      CALC.TPU (2.0)            TP5.X Compiled Unit             CALC.TPU (2.0)
  63.  
  64.  
  65.           by  binding  it  to  a  key  and   calling   the   procedure
  66.           "Calculator",  in  much  the same way a help screen might be
  67.           called.  
  68.           
  69.           The CALC.TPU defaults are: 
  70.           
  71.           * Do not wait for retrace.
  72.           * Window border color is white (15).
  73.           * Calculator display is white.
  74.           * Keyboard number lock is set on.
  75.           
  76.           When calling the calculator, the current screen (CGA,  MONO,
  77.           EGA,  VGA,  MCGA,  80  column text mode only) is saved and a
  78.           window is opened displaying whatever the  developer  decides
  79.           the installed calculator should look.  
  80.           
  81.           OPERATION 
  82.           
  83.           The   window   can  be  moved  across  the  screen  in  five
  84.           character-cell steps, to allow any on screen  values  to  be
  85.           seen from  the  application  below.  The normal numeric keys
  86.           and +, -, /, and * perform the normal  four  functions,  and
  87.           the  c,  e =, or <enter> provide Clear all, clear Entry, and
  88.           total functions.  The right and left  arrow  keys  move  the
  89.           calculator window  on the screen.  On the enhanced keyboard,
  90.           the cursor pad will  allways  be  "on",  but  on  the  older
  91.           keyboard the  cursor  and  numeric functions are shared.  If
  92.           EnhncdKeyboard  is  set  to  FALSE,  then  the   user   will
  93.           automatically have  the number pad turned on.  The shift key
  94.           must then be pressed to use the right and left arrow keys to 
  95.           move the calculator across the screen.  
  96.           
  97.           The user may return to the application by hitting the escape 
  98.           key.  When the calculator is called upon for later use,  the
  99.           last  calculation  is  still intact and it returns to the on
  100.           screen position last set by the user.   The  programmer  may
  101.           write  code  (see  the example in SAMPLE.PAS) to utilize the
  102.           value placed in the variable "PasteValue", when the exit  is
  103.           performed by the F10 key from within the calculator.  
  104.           
  105.           FLEXIBILITY 
  106.  
  107.  
  108.  
  109.           
  110.                                       -2-
  111.  
  112.  
  113.  
  114.  
  115.  
  116.      CALC.TPU (2.0)            TP5.X Compiled Unit             CALC.TPU (2.0)
  117.  
  118.  
  119.           By  managing  its  own window, CALC.TPU frees the programmer
  120.           from additional interface requirements.  Developers  wanting
  121.           to control window management must purchase the source code.  
  122.           
  123.           Screen  colors,  number  pad control, and "wait for retrace"
  124.           may be set  by  the  programmer,  or  by  the  user  if  the
  125.           programmer has   a  general  installation  procedure.    The
  126.           calculator has an exit flag (PasteExit : Boolean;) to  allow
  127.           the  programmer  to  determine  if the users exit requires a
  128.           value (PasteValue : String) be pasted into the application.  
  129.           
  130.           By purchasing  the  source code,  changes can be made in the
  131.           code to allow its use across networks,  utilize  a   numeric
  132.           coprocessor,  or  it  may  be  modified  for  use  in  XENIX
  133.           applications using one of the PASCAL compilers available for 
  134.           that Operating system (I read  somewhere  that  BORLAND  may
  135.           port  its  languages  to XENIX or UNIX and that OS2 versions
  136.           were coming soon).  
  137.           
  138.  
  139.      LICENSE REQUIREMENTS 
  140.           
  141.           CALC.TPU UNIT LICENSE 
  142.           
  143.           A developer wishing to compile the unit, CALC.TPU,  into  an
  144.           application  may do so by completing the License application
  145.           in this ARC file and returning it  with  a  Check  or  Money
  146.           order for Twenty Dollars ($20.00). The developer may use the 
  147.           unit,  CALC.TPU in any number of applications for private or
  148.           commercial use.  There are no royalties or  other  fees  for
  149.           the use  of  the  unit CALC.TPU in an application.  CALC.TPU
  150.           may not be distributed with any other software unless in the 
  151.           form of the full ARC file, with all sample files,  CALC.TPU,
  152.           META  files,  license  form,  and  this  documentation  file
  153.           present.  
  154.           
  155.           CALC.PAS SOUCRE CODE LICENSE 
  156.           
  157.           The source code to CALC.TPU may also be purchased for  Sixty
  158.           dollars ($60.00).    The  license form must be completed and
  159.  
  160.  
  161.  
  162.  
  163.                                       -3-
  164.  
  165.  
  166.  
  167.  
  168.  
  169.      CALC.TPU (2.0)            TP5.X Compiled Unit             CALC.TPU (2.0)
  170.  
  171.  
  172.           returned along with a check or money order for Sixty dollars 
  173.           ($60.00).  When  purchasing  the  source  do  not  send  any
  174.           additional  for  the  TPU.  The  source license includes the
  175.           TPU.  Purchasing the source code allows  one  to  add  other
  176.           features   such   as   memory  variable  keys,  percent  key
  177.           operation, number base conversion, paper  tape  printing  to
  178.           file,  printer  or  screen,  slide rule functions, and other
  179.           features.  The source will be delivered on 5 1/4", 360K, IBM 
  180.           compatible floppy or on 3 1/2", 720K, IBM compatible floppy, 
  181.           or on both for an additional $3.00. Also included  with  the
  182.           media  is  a  fully  commented  source  listing  with  cross
  183.           reference  for  all  label,  constants,  types,   variables,
  184.           procedures, and functions.  
  185.           
  186.           Also available in source code form is the same calculator as 
  187.           an  include  file  for  Turbo  Pascal  Version 3 (TP3). This
  188.           include file adds approx.  5k to an executable TP3  program.
  189.           The cost of this file is Sixty dollars ($60.00).  
  190.           
  191.           The  source code to CALC.TPU, and the TP3 version, CALC.INC,
  192.           remains the property of Timothy B. Coleman and  may  not  be
  193.           distributed  in  printed or electronic form, or on magenetic
  194.           media, or any other media.  It is the responsibility of  the
  195.           programmer using this source code to respect its proprietary 
  196.           nature.  
  197.           
  198.           Upon  receipt  of  your  license application, a registration
  199.           form, and source code  for  those  requesting  it,  will  be
  200.           mailed within two days.  
  201.           
  202.           The  META files, both source and TPU, are available with the
  203.           SHAREWARE release of CALC.TPU, and may be modified freely.  
  204.           
  205.           Following the simple methodology used by the  calculator,  a
  206.           programmer  may  add  many additional functions suitable for
  207.           the specific application being  designed.    Purchasing  the
  208.           source  will also allow simple recoding to support terminals
  209.           and network applications.  
  210.           
  211.  
  212.      INTERFACE 
  213.  
  214.  
  215.  
  216.           
  217.                                       -4-
  218.  
  219.  
  220.  
  221.  
  222.  
  223.      CALC.TPU (2.0)            TP5.X Compiled Unit             CALC.TPU (2.0)
  224.  
  225.  
  226.           The unit file has the following interface: 
  227.           
  228.           Uses 
  229.             Crt,
  230.              meta,
  231.              cursors,
  232.              fastWr;
  233.             Procedure Calculator;
  234.             Var PasteValue : String;
  235.              {Contains the result of a calculation.}
  236.  
  237.             PasteExit : Boolean;
  238.              {Flag indicating the result should be pasted.}
  239.             KillSnow : Boolean;
  240.              {If set to TRUE screen writes wait for retrace.}
  241.             BoxTint : Integer;
  242.              {Color of the window border.}
  243.             ValueTint : Integer;
  244.              {Color of number written to the display}
  245.             EnhncdKeyboard : Boolean;
  246.              {If set to TRUE number locks not turned on.}
  247.           
  248.             Unit name:          CALC
  249.             Total code:         3495
  250.             Initialized data:   72
  251.             Uninitialized data: 5594
  252.             Symbol table:       773
  253.             Relocation table:   3168
  254.             Line number table:  0
  255.             Numeric processing: $N-
  256.  
  257.  
  258.      ACKNOWLEDGEMENTS 
  259.           
  260.           The sometimes unpredictable and  inconsistent  operation  of
  261.           the TP5 Write and Writeln procedures, led me to the decision
  262.           to utilize  Brian  Foley's  SUPER!  Public Domain procedure,
  263.           FASTWR.TPU.  This  file   (FASTWR.ARC)   is   available   on
  264.           CompuServe  in  the  Borland  Library  (GO  BOR-100, LIB 2).
  265.  
  266.  
  267.  
  268.  
  269.                                       -5-
  270.  
  271.  
  272.  
  273.  
  274.  
  275.      CALC.TPU (2.0)            TP5.X Compiled Unit             CALC.TPU (2.0)
  276.  
  277.  
  278.           FASTWR is used to draw the window  and  to  display  entered
  279.           values and  results on the screen.  FASTWR writes to the crt
  280.           much faster than TP5.X's own Write and it allows positioning
  281.           and color  selection  in one command.  I also used FASTWR in
  282.           the META file for the  calculator  image  or  metaphor.    I
  283.           suggest the use of FASTWR.TPU in any programmer created META 
  284.           file, but  other  routines  should work fine.  If you cannot
  285.           find FASTWR.ARC or did not get this  file  from  CompuServe,
  286.           include  a note, when you mail your license form, requesting
  287.           a copy and I'll send it with your Registration form.  
  288.           
  289.           Also utilized, is the Public Domain routines in  CURSORS.TPU
  290.           by  Scott  Bussinger,  Professional  Practice  Systems, ver.
  291.           1.02. CURSORS.TPU is used in CALC.TPU to  blank  the  cursor
  292.           during  calculator  use,  and  to retore it and its original
  293.           position after use.  
  294.           
  295.           Thanks to Brian Foley and Scott Bussinger for writing  those
  296.           fine routines.  
  297.           
  298.  
  299.      APPLICATIONS 
  300.           
  301.           Now that TP  allows the executable program to be up 640K, it
  302.           is  easy  to  build a friendlier, more complete application.
  303.           The addition of a calculator may at first thought seem to be 
  304.           rather a rudimentary improvement.  With cheap four  function
  305.           calculators  costing  about  five  bucks  ($5.00), why worry
  306.           about adding one to  an  application?    Probably  the  best
  307.           justification  is  that  a user cannot paste the result of a
  308.           calculation from a handheld unit  into  the  application  on
  309.           screen.   The  possibility of making an error in transfering
  310.           the number is eliminated.  Popup windows have proven to be a 
  311.           popular way of presenting information, and a useful  way  of
  312.           doing  something  else while in the context of a prior task.
  313.           Many applications can benefit  from  the  addition  of  this
  314.           professional appearing,  windowed  calculator.   The changes
  315.           can be made to most TP5.X programs in 5 to 15 minutes!  Here
  316.           are some example applications:
  317.  
  318.           * Point of sale software.
  319.           * Payroll Programs
  320.           
  321.  
  322.  
  323.  
  324.  
  325.                                       -6-
  326.  
  327.  
  328.  
  329.  
  330.  
  331.      CALC.TPU (2.0)            TP5.X Compiled Unit             CALC.TPU (2.0)
  332.  
  333.  
  334.           
  335.           * Accounting Packages.
  336.           * DataBase management software.
  337.           * Word Processing software.
  338.           * Text Editors.
  339.           * Communication Software.
  340.           * SpreadSheet programs.
  341.           * Project management Software.
  342.           * Desktop management applications.
  343.           * Integrated Software (call from any part of the program).
  344.  
  345.           Remember   also   that   while   TSR  programs,  along  with
  346.           sophisticated environments such as  MicroSoft  Windows,  all
  347.           provide  built  in  calculators, these programs can use vast
  348.           amounts of memory  and  may  not  work  smoothly  with  your
  349.           application.   It  has  also  been  stated that TSR programs
  350.           should not be used in the  Compatibility Box under OS2.  TSR
  351.           programs   also  do  not  work  well  in  environments  like
  352.           PC-MOS/386. It is therefore more  important  that  your  new
  353.           application include proven, useful desktop applications such 
  354.           as CALC.TPU.
  355.  
  356.      FILES 
  357.           
  358.           Files included in the ARC file are listed below: 
  359.           
  360.           CALC     TPU - The calculator unit.
  361.           CALC     DOC - This documentation file.
  362.           META1    PAS - A metaphor of a large handheld calculator.
  363.           META1    TPU - The compiled unit.
  364.           META2    TPU - The metaphor of a small handheld calculator.
  365.           META2    PAS - The compiled unit.
  366.           META3    TPU - A tiny window at the top of the screen.
  367.           META3    PAS - The compiled unit.
  368.           READ     ME  - Read this file FIRST.
  369.           SAMPLE   EXE - A sample program demonstarting all Features
  370.           SAMPLE   PAS - Source for the sample executable.
  371.           LICENSE  FRM - The license form to be printed and mailed.
  372.           PRINTDOC BAT - A batch file to print this file and the
  373.                          license.
  374.           All  source  code is completely commented to insure that you
  375.           can implement CALC.TPU into your application in MINUTES!!
  376.  
  377.  
  378.  
  379.  
  380.  
  381.                                       -7-
  382.  
  383.  
  384.  
  385.  
  386.      CALC.TPU (2.0)            TP5.X Compiled Unit             CALC.TPU (2.0)
  387.           
  388.  
  389.      COMPILING 
  390.           
  391.           To compile CALC.TPU into an application, you must rename one 
  392.           of the meta files from meta1, meta2, or meta3, to meta.   If
  393.           you are compiling one of the meta source files you must have 
  394.           FASTWR.TPU  (or  recode  to  support  your choice of display
  395.           routines.) where the compiler  can  locate  it,  along  with
  396.           CALC.TPU.   Read  the  file SAMPLE.PAS to see how things are
  397.           coded.  
  398.           
  399.           The keyboard buffer is  the  perfect  place  to  send  alpha
  400.           numeric charcters  from the calculator.  One method of doing
  401.           this is listed below: 
  402.           
  403.           PROCEDURE BufIn(PushInt : Integer); 
  404.           BEGIN
  405.             INLINE
  406.             ($1E/
  407.             $B8/$40/$00/
  408.             $8E/$D8/
  409.             $FA/
  410.             $8B/$46/$04/
  411.             $8B/$1E/$1C/$00/
  412.             $89/$07/
  413.             $83/$C3/$02/
  414.             $3B/$1E/$82/$00/
  415.             $79/$07/
  416.             $89/$1E/$1C/$00/
  417.             $EB/$09/$90/
  418.             $8B/$1E/$80/$00/
  419.             $89/$1E/$1C/$00/
  420.             $FB/
  421.             $1F);
  422.           END;
  423.  
  424.           This code was captured from a Borland forum discussion and I
  425.           cannot remember whom to credit.
  426.  
  427.           FOR index := 1 to Length(LastOper)  DO
  428.           BEGIN
  429.             PushInt := Integer(PasteValue[index]);
  430.             BufIn(PushInt);
  431.           END;
  432.  
  433.           The code fragment above is used to stuff characters one at a
  434.           time, into the keyboard routine, BufIn.   One  other  simple
  435.           method of stuffing the buffer is given in the  file  KBD.ARC
  436.           on  CompuServe's Borland SIG in LIB 2. Any number of methods
  437.           may be used to put the result of  a  calculation  into  your
  438.  
  439.  
  440.  
  441.                                       -8-
  442.  
  443.  
  444.  
  445.  
  446.  
  447.      CALC.TPU (2.0)            TP5.X Compiled Unit             CALC.TPU (2.0)
  448.  
  449.  
  450.           application.  
  451.           
  452.           After  reading  the  file SAMPLE.PAS, you may want to change
  453.           the colors, set the variable, enhncdkeyboard, for your  type
  454.           of keyboard, and rename one of the meta files and  recompile
  455.           to see first hand how easy it is to make the calculator look
  456.           any way you wish.  
  457.           
  458.  
  459.      HISTORY 
  460.           
  461.           CALC.TPU  was  originally  a  procedure I wrote for a custom
  462.           Database mgmt. and billing system  I was  designing,  for  a
  463.           market   that  shall  remain  unnamed  since  I  have  don't
  464.           presently have any competition.  It  worked so well  that  I
  465.           decided  to convert it to a stand-alone TP3 program and make
  466.           it PUBLIC DOMAIN. Within months, I had moved it into  a  TSR
  467.           calculator  (also  PUBLIC DOMAIN). Both went through several
  468.           revisions and with user feedback, small bugs were identified
  469.           and eliminated.   Enhancments were added with every release.
  470.           Both programs are  still  available  on  CompuServe's  IBMSW
  471.           software  forum  in  LIB  12. The programs are FFC45.ARC and
  472.           FFNC74.ARC.  
  473.           
  474.           What I have delivered to you in CALC.TPU ver.  1.0 is not  a
  475.           beta  file,  but  a  completely  debugged, enhanced product,
  476.           tested by thousands of users.  During the past two years,  I
  477.           have  received  countless  letters,  and Email regarding the
  478.           calculator in either TSR or stand alone form.  This response 
  479.           makes believe any application utilizing CALC.TPU can only be 
  480.           improved by its presence.  Try comparing its output to  your
  481.           own four function calculator.
  482.  
  483.  
  484.      WARNINGS 
  485.           
  486.           The use of TP's  floating point emulator has a range of  2.9
  487.           X  10E-39  to  1.7 X 10E38, and 11 to 12 significant digits.
  488.           While code has been added to prevent divide by zero  errors,
  489.           it  is  possible for a user to continually increment a value
  490.           with multiplication to the point  of  forcing  an  overflow.
  491.           This  is  not  a  serious  event if you use a critical error
  492.           handler to intercept errors in a controlled manner.  When an
  493.  
  494.  
  495.  
  496.  
  497.                                       -9-
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.      CALC.TPU (2.0)            TP5.X Compiled Unit             CALC.TPU (2.0)
  506.  
  507.  
  508.           error  occurs, the  critical  handler  can  take  over   and
  509.           promoptly  close  all  open  files and allow an orderly shut
  510.           down.  Under these circumstances, the user should be able to 
  511.           restart with no loss of current data.  Code is available  on
  512.           CompuServe  in the  Borland SIG (LIB 1) from a back issue of
  513.           Turbo   Technix  Magazine  that   provides  excellent   code
  514.           fragments from which  a programmer can build a useful  error
  515.           handler to suit the application.
  516.           
  517.  
  518.           Mail license forms and fee to:
  519.  
  520.           
  521.           Timothy B. Coleman
  522.           11115 Kenmoor Drive
  523.           Detroit, Michigan 48205
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.                                       -10-
  556.  
  557.          ----------------end-of-author's-documentation---------------
  558.  
  559.                         Software Library Information:
  560.  
  561.                    This disk copy provided as a service of
  562.  
  563.                         The Public (Software) Library
  564.  
  565.          We are not the authors of this program, nor are we associated
  566.          with the author in any way other than as a distributor of the
  567.          program in accordance with the author's terms of distribution.
  568.  
  569.          Please direct shareware payments and specific questions about
  570.          this program to the author of the program, whose name appears
  571.          elsewhere in  this documentation. If you have trouble getting
  572.          in touch with the author,  we will do whatever we can to help
  573.          you with your questions. All programs have been tested and do
  574.          run.  To report problems,  please use the form that is in the
  575.          file PROBLEM.DOC on many of our disks or in other written for-
  576.          mat with screen printouts, if possible.  The P(s)L cannot de-
  577.          bug programs over the telephone.
  578.  
  579.          Disks in the P(s)L are updated monthly, so if you did not get
  580.          this disk  directly from the P(s)L,  you should be aware that
  581.          the files in this set may no  longer be the current versions.
  582.  
  583.          For a copy of the latest monthly software library newsletter
  584.          and a list of the 2,000+ disks in the library, call or write
  585.  
  586.                         The Public (Software) Library
  587.                               P.O.Box 35705 - F
  588.                            Houston, TX 77235-5705
  589.                             Orders: 800-2424-PSL
  590.                             Info:   713-524-6394
  591.                             FAX #:  713-524-6398
  592.                             CIS ID: 71355,470
  593.  
  594.